<!--
 * @Author: your name
 * @Date: 2021-08-31 17:29:16
 * @LastEditTime: 2021-09-01 08:37:52
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-admin-template\src\components\Lang\index.vue
-->
<template>
  <div class="container">
    <el-dropdown trigger="click" @command="changeLanguage">
      <div>
        <svg-icon style="color:#fff;font-size:20px" icon-class="language" />
      </div>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="zh" :disabled="'zh'=== $i18n.locale ">中文</el-dropdown-item>
        <el-dropdown-item command="en" :disabled="'en'=== $i18n.locale ">English</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>

</template>
<script>
export default {
  name: 'Lang',
  methods: {
    // 点击每一项时触发的方法
    // 形参是 el-dropdown-item 组件的 command 属性的属性值
    changeLanguage(command) {
      this.$i18n.locale = command

      localStorage.setItem('lang', command)
      console.log(this.$route)
      this.$router.push(this.$route.fullPath)
    }
  }
}
</script>
<style scoped lang="scss"></style>
